package com.zmzncs.lmtc.module.park.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmzncs.lmtc.common.config.ClientConfig;
import com.zmzncs.lmtc.common.pojo.tengda.*;
import com.zmzncs.lmtc.common.util.BolianUtil;
import com.zmzncs.lmtc.common.util.DateTimeUtil;
import com.zmzncs.lmtc.module.customer.dao.CarDao;
import com.zmzncs.lmtc.module.customer.pojo.car.CarDTO;
import com.zmzncs.lmtc.module.order.dao.OrderInfoDao;
import com.zmzncs.lmtc.module.order.dao.OrderTradeRecordDao;
import com.zmzncs.lmtc.module.order.pojo.orderInfo.OrderInfo;
import com.zmzncs.lmtc.module.order.pojo.orderInfo.OrderInfoDTO;
import com.zmzncs.lmtc.module.order.service.OrderInfoService;
import com.zmzncs.lmtc.module.park.dao.ParkInfoDao;
import com.zmzncs.lmtc.module.park.pojo.parkinfo.ParkInfoDTO;
import com.zmzncs.lmtc.module.park.service.ParkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * <p>
 * 订单
 * </p>
 *
 * @author
 * @since 2020-09-01
 */
@Slf4j
@Service
public class ParkServiceImpl implements ParkService {

    @Autowired
    OrderInfoDao orderInfoDao;
    @Autowired
    OrderTradeRecordDao orderTradeRecordDao;

    @Autowired
    HttpServletRequest request;

    @Value("${pay-test}")
    boolean payTest;

    public static List<TengdaForm> tengdaParkFormList = new ArrayList<>();

    /**
     * 删除缓存
     */
    @Override
    @Async("threadPoolExecutor")
    public void deleteCache(TengdaForm form) {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //  删除缓存
        tengdaParkFormList.remove(form);
    }

    /**
     * 车辆类型
     */
    @Override
    public void carTypes(TengdaForm form) {
        log.info("车辆类型通知【{}】", form);
        log.info("车辆类型通知-业务数据【{}】", form.getDataItems());

        tengdaParkFormList.add(form);
        log.info("车辆类型通知-缓存业务数据【{}】", tengdaParkFormList);
    }

    /**
     * 获取通道列表
     */
    @Override
    public void allChannels(TengdaForm form) {
        log.info("获取通道列表通知【{}】", form);
        log.info("获取通道列表通知-业务数据【{}】", form.getDataItems());

        tengdaParkFormList.add(form);
        log.info("获取通道列表通知-缓存业务数据【{}】", tengdaParkFormList);
    }

}
